<template>
  <el-card style="height: 70px">
    <el-form inline="true">
      <el-form-item label="一级分类">
        <el-select
          size="small"
          :disabled="!isShowTable"
          v-model="categoryStore.c1Id"
          @change="handler1Id"
        >
          <el-option
            v-for="c1 in categoryStore.c1Arr"
            :key="c1.id"
            :label="c1.name"
            :value="c1.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="二级分类">
        <el-select
          size="small"
          :disabled="!isShowTable"
          v-model="categoryStore.c2Id"
          @change="handler2Id"
        >
          <el-option
            v-for="c2 in categoryStore.c2Arr"
            :key="c2.id"
            :label="c2.name"
            :value="c2.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="三级分类">
        <el-select
          size="small"
          :disabled="!isShowTable"
          v-model="categoryStore.c3Id"
        >
          <el-option
            v-for="c3 in categoryStore.c3Arr"
            :key="c3.id"
            :label="c3.name"
            :value="c3.id"
          ></el-option>
        </el-select>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script lang="ts" setup>
import useCategoryStore from '@/store/modules/Category'
const categoryStore = useCategoryStore()
import { onMounted } from 'vue'
defineProps(['isShowTable'])
onMounted(() => {
  categoryStore.getC1Data()
})
const handler1Id = () => {
  categoryStore.c2Id = ''
  categoryStore.c3Id = ''
  categoryStore.c3Arr = []
  categoryStore.getC2Data()
}
const handler2Id = () => {
  categoryStore.c3Id = ''
  categoryStore.getC3Data()
}
</script>

<style lang="scss" scoped></style>
